import argparse
import os
from concurrent.futures import ThreadPoolExecutor


def run_single_compare(source_path, follow_path, api_name, output_path):
    os.system("python3 compare_results.py --source_path=%s --follow_path=%s --api_name=%s --output_path=%s"
              % (source_path, follow_path, api_name, output_path))


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    # Granularity : Model-Level / API-Level / Experiment-Level
    path = "/home/ubuntu/Ascend/phase2_20221231/results/tf2cann/tensorflow-gpu2"
    current_path = os.path.dirname(os.path.abspath(__file__))
    parser.add_argument("-s", "--source_path", default=path, help="The output of source model.")
    path = "/home/ubuntu/Ascend/phase2_20221231/results/tf2cann/om"
    parser.add_argument("-f", "--follow_path", default=path, help="The output of follow-up model.")
    parser.add_argument("-o", "--output_path", default=os.path.join(current_path, "results"))
    args = parser.parse_args()

    pool = ThreadPoolExecutor(30)
    api_list = os.listdir(args.source_path)
    for api in api_list:
        print("[BATCH COMPARE RESULTS] running API %s results comparing...." % api)
        pool.submit(run_single_compare, args.source_path, args.follow_path, api, args.output_path)







